package com.teemo.equipment.biz.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.teemo.equipment.biz.HeroBizService;
import com.teemo.equipment.converter.HeroMapStruct;
import com.teemo.equipment.domain.dto.HeroPageDTO;
import com.teemo.equipment.domain.entity.Hero;
import com.teemo.equipment.domain.vo.BasePageVO;
import com.teemo.equipment.domain.vo.HeroDetailVO;
import com.teemo.equipment.domain.vo.HeroPageVO;
import com.teemo.equipment.service.HeroService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * @author Teemo
 */
@Service
public class HeroBizServiceImpl implements HeroBizService {

    @Resource
    private HeroService heroService;

    @Override
    public BasePageVO<HeroPageVO> page(HeroPageDTO dto) {
        Page<Hero> page = heroService.pageQuery(dto);
        BasePageVO<HeroPageVO> result = BasePageVO.convert(page, HeroMapStruct.INSTANCE::toHeroPageVO);
        return result;
    }

    @Override
    public HeroDetailVO detail(Long id) {
        Hero hero = heroService.checkById(id);
        return HeroMapStruct.INSTANCE.toHeroDetailVO(hero);
    }
}
